package com.lcxw.hxzbapi.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lcxw.hxzbapi.dao.mapper.CubeDrawRecordMapper;
import com.lcxw.hxzbapi.entity.pojo.CubeDrawRecord;
import com.lcxw.hxzbapi.entity.pojo.ShortVideoComment;
import com.lcxw.hxzbapi.entity.response.CubeDrawRecordForMem;
import com.lcxw.hxzbapi.entity.response.Response;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class CubeDrawRecordService {

    @Resource
    CubeDrawRecordMapper cubeDrawRecordMapper;

    public int insert(CubeDrawRecord cubeDrawRecord) {
        return cubeDrawRecordMapper.insert(cubeDrawRecord);
    }

    public List<String> selectAddTimeGroup(long userId) {

        return cubeDrawRecordMapper.selectAddTimeGroup(userId);
    }


    public List<CubeDrawRecord> selectByUserId(long userId) {
        QueryWrapper<CubeDrawRecord> wrapper = new QueryWrapper<>();
        wrapper.eq("userId", userId);
        wrapper.orderByDesc("addTime");
        return cubeDrawRecordMapper.selectList(wrapper);

    }

    public List<CubeDrawRecord> selectByUserId(long userId, int pageNum, int pageSize) {
        IPage<CubeDrawRecord> iPage = new Page<>(pageNum, pageSize);
        QueryWrapper<CubeDrawRecord> wrapper = new QueryWrapper<>();
        wrapper.eq("userId", userId);
        wrapper.groupBy("addTime");
        wrapper.orderByDesc("addTime");
        IPage<CubeDrawRecord> cubeDrawRecordIPage = cubeDrawRecordMapper.selectPage(iPage, wrapper);
        return cubeDrawRecordIPage.getRecords();
    }

    public List<CubeDrawRecord> getAll() {
        return cubeDrawRecordMapper.selectList(null);
    }

    public List<Long> selectAllUserId() {
        return cubeDrawRecordMapper.selectAllUserId();
    }


    public List<Long> selectTodayUser() {
        return cubeDrawRecordMapper.selectTodayUser();
    }

    public List<CubeDrawRecord> selectTodayListUser(Long userId) {
        return cubeDrawRecordMapper.selectTodayListUser(userId);
    }

    public int getOneGiftCount(int giftNum, int giftId) {
        return cubeDrawRecordMapper.getOneGiftCount(giftNum, giftId);
    }

    public int getCount() {
        return cubeDrawRecordMapper.selectCount(null);
    }

    public List<CubeDrawRecordForMem> getRecords(int pageNum, int pageSize) {
        return cubeDrawRecordMapper.getRecords(pageNum, pageSize);
    }


    public List<CubeDrawRecordForMem> getRecords(String type) {
        return cubeDrawRecordMapper.getNotices(type);
    }

    public List<CubeDrawRecordForMem> getLists(String addTime,String userId) {
        return cubeDrawRecordMapper.getLists(addTime,userId);
    }
}
